using System;
using System.Collections.Generic;
using HotelManageSystem.Model;
using Microsoft.EntityFrameworkCore;

namespace HotelManageSystem.Data;

public partial class DataContext : DbContext {
    public DataContext(DbContextOptions<DataContext> options) : base(options) {

    }

    public DbSet<User> Users => Set<User>();
    public DbSet<Worker> Workers => Set<Worker>();
    public DbSet<Room> Rooms => Set<Room>();
    public DbSet<Bill> Bills => Set<Bill>();
    public DbSet<RType> RTypes => Set<RType>();


    public DbSet<CheckIn_UserWorkerRoom> CheckIn_UserWorkerRooms => Set<CheckIn_UserWorkerRoom>();
    public DbSet<PreOrder_UserWorkerRoom> PreOrder_UserWorkerRooms => Set<PreOrder_UserWorkerRoom>();

    protected override void OnModelCreating(ModelBuilder modelBuilder) {
        modelBuilder.Entity<User>(entity => {
            entity.Property(c => c.Id).ValueGeneratedNever();// 关闭数据表列的自动增长
            entity.HasData(
                new User { Id = "430521200110107551", Name = "罗一", Gender = EnumGender.Male, ContactType = EnumContactType.Telephone, ContactData = "18978162304" }
            );
        });

        modelBuilder.Entity<Worker>(entity => {
            //entity.Property(c => c.Id).ValueGeneratedNever();
            entity.HasData(
                new Worker { Id = 1, Name = "罗二", Gender = EnumGender.Male, Job = EnumWorkerJob.管理员, ContactType = EnumContactType.Telephone, ContactData = "18978162304", }
            );
        });

        modelBuilder.Entity<Room>(entity => {
            entity.Property(c => c.Id).ValueGeneratedNever();// 关闭数据表列的自动增长
            entity.HasData(
                new Room { Id = 2003, Price = 350, Model = EnumRoomModel.总统套房电竞房, State = EnumRoomState.空闲 },
                new Room { Id = 1001, Price = 350, Model = EnumRoomModel.豪华大床房, State = EnumRoomState.空闲 },
                new Room { Id = 1002, Price = 350, Model = EnumRoomModel.双人间, State = EnumRoomState.空闲 },
                new Room { Id = 1003, Price = 350, Model = EnumRoomModel.标间, State = EnumRoomState.空闲 },
                new Room { Id = 1004, Price = 350, Model = EnumRoomModel.标间, State = EnumRoomState.空闲 },
                new Room { Id = 1005, Price = 350, Model = EnumRoomModel.标间, State = EnumRoomState.空闲 },
                new Room { Id = 1006, Price = 350, Model = EnumRoomModel.标间, State = EnumRoomState.空闲 },
                new Room { Id = 1007, Price = 350, Model = EnumRoomModel.标间, State = EnumRoomState.空闲 }
            );
        });

        modelBuilder.Entity<RType>(entity => {
            entity.Property(c => c.Id).ValueGeneratedNever();// 关闭数据表列的自动增长
            entity.HasData(
                new RType { Id = EnumRoomModel.豪华大床房,Price=1000 },
                new RType { Id = EnumRoomModel.总统套房电竞房, Price = 500 },
                new RType { Id = EnumRoomModel.双人间, Price = 250 },
                new RType { Id = EnumRoomModel.标间, Price = 100 }
            );
        });

        modelBuilder.Entity<CheckIn_UserWorkerRoom>(entity => {
            entity.Property(c => c.Id).ValueGeneratedOnAdd();// 开启数据表列的自动增长
        });

        modelBuilder.Entity<PreOrder_UserWorkerRoom>(entity => {
            entity.Property(c => c.Id).ValueGeneratedOnAdd();// 开启数据表列的自动增长
        });


    }
}

